package org.gap.domain;

import java.io.Serializable;

import java.lang.StringBuilder;

import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import javax.xml.bind.annotation.*;

import javax.persistence.*;

/**
 */

@Entity
@NamedQueries({
		@NamedQuery(name = "findAllRelationss", query = "select myRelations from Relations myRelations"),
		@NamedQuery(name = "findRelationsByPrimaryKey", query = "select myRelations from Relations myRelations where myRelations.relRelation = ?1"),
		@NamedQuery(name = "findRelationsByRelLibelleAsc", query = "select myRelations from Relations myRelations where myRelations.relLibelleAsc = ?1"),
		@NamedQuery(name = "findRelationsByRelLibelleAscContaining", query = "select myRelations from Relations myRelations where myRelations.relLibelleAsc like ?1"),
		@NamedQuery(name = "findRelationsByRelLibelleDesc", query = "select myRelations from Relations myRelations where myRelations.relLibelleDesc = ?1"),
		@NamedQuery(name = "findRelationsByRelLibelleDescContaining", query = "select myRelations from Relations myRelations where myRelations.relLibelleDesc like ?1"),
		@NamedQuery(name = "findRelationsByRelRelation", query = "select myRelations from Relations myRelations where myRelations.relRelation = ?1"),
		@NamedQuery(name = "findRelationsByRelRelationContaining", query = "select myRelations from Relations myRelations where myRelations.relRelation like ?1"),
		@NamedQuery(name = "findRelationsByRelType", query = "select myRelations from Relations myRelations where myRelations.relType = ?1"),
		@NamedQuery(name = "findRelationsByRelTypeContaining", query = "select myRelations from Relations myRelations where myRelations.relType like ?1") })
@Table(schema = "GAP", name = "RELATIONS")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "GAP_v2/org/gap/domain", name = "Relations")
@XmlRootElement(namespace = "GAP_v2/org/gap/domain")
public class Relations implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 */

	@Column(name = "REL_RELATION", length = 3, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@Id
	@XmlElement
	String relRelation;
	/**
	 */

	@Column(name = "REL_LIBELLE_DESC", length = 40)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String relLibelleDesc;
	/**
	 */

	@Column(name = "REL_LIBELLE_ASC", length = 40)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String relLibelleAsc;
	/**
	 */

	@Column(name = "REL_TYPE", length = 40)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String relType;

	/**
	 */
	@OneToMany(mappedBy = "relations", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)
	@XmlElement(name = "", namespace = "")
	java.util.Set<org.gap.domain.RelationsTiers> relationsTierses;

	/**
	 */
	public void setRelRelation(String relRelation) {
		this.relRelation = relRelation;
	}

	/**
	 */
	public String getRelRelation() {
		return this.relRelation;
	}

	/**
	 */
	public void setRelLibelleDesc(String relLibelleDesc) {
		this.relLibelleDesc = relLibelleDesc;
	}

	/**
	 */
	public String getRelLibelleDesc() {
		return this.relLibelleDesc;
	}

	/**
	 */
	public void setRelLibelleAsc(String relLibelleAsc) {
		this.relLibelleAsc = relLibelleAsc;
	}

	/**
	 */
	public String getRelLibelleAsc() {
		return this.relLibelleAsc;
	}

	/**
	 */
	public void setRelType(String relType) {
		this.relType = relType;
	}

	/**
	 */
	public String getRelType() {
		return this.relType;
	}

	/**
	 */
	public void setRelationsTierses(Set<RelationsTiers> relationsTierses) {
		this.relationsTierses = relationsTierses;
	}

	/**
	 */
	public Set<RelationsTiers> getRelationsTierses() {
		if (relationsTierses == null) {
			relationsTierses = new java.util.LinkedHashSet<org.gap.domain.RelationsTiers>();
		}
		return relationsTierses;
	}

	/**
	 */
	public Relations() {
	}

	/**
	 * Copies the contents of the specified bean into this bean.
	 *
	 */
	public void copy(Relations that) {
		setRelRelation(that.getRelRelation());
		setRelLibelleDesc(that.getRelLibelleDesc());
		setRelLibelleAsc(that.getRelLibelleAsc());
		setRelType(that.getRelType());
		setRelationsTierses(new java.util.LinkedHashSet<org.gap.domain.RelationsTiers>(that.getRelationsTierses()));
	}

	/**
	 * Returns a textual representation of a bean.
	 *
	 */
	public String toString() {

		StringBuilder buffer = new StringBuilder();

		buffer.append("relRelation=[").append(relRelation).append("] ");
		buffer.append("relLibelleDesc=[").append(relLibelleDesc).append("] ");
		buffer.append("relLibelleAsc=[").append(relLibelleAsc).append("] ");
		buffer.append("relType=[").append(relType).append("] ");

		return buffer.toString();
	}

	/**
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = (int) (prime * result + ((relRelation == null) ? 0 : relRelation.hashCode()));
		return result;
	}

	/**
	 */
	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof Relations))
			return false;
		Relations equalCheck = (Relations) obj;
		if ((relRelation == null && equalCheck.relRelation != null) || (relRelation != null && equalCheck.relRelation == null))
			return false;
		if (relRelation != null && !relRelation.equals(equalCheck.relRelation))
			return false;
		return true;
	}
}
